<template>
  <div id="myBar1" :style="{ width: '460px', height: '285px' }"></div>
</template>

<script>
export default {
  name: "pie1",
  props: {
    bar1data: {
      type: Array,
      default: function () {
        return [];
      },
    },
  },
  data() {
    return {};
  },
  watch: {
    bar1data() {
      this.init();
    },
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      let bar1 = this.$echarts.init(document.getElementById("myBar1"));
      bar1.setOption({
        title: {
          //   text: "关键技术数量",
          //   y: "center",
        },
        legend: {},
        tooltip: {},
        // dataset: {
        //   dimensions: ["product", "A", "B", "C"],
        //   source: [
        //     {
        //       product: this.bar1data[0].name,
        //       A: this.bar1data[0].value[0].value,
        //       B: this.bar1data[0].value[1].value,
        //       C: this.bar1data[0].value[2].value,
        //     },
        //   ],
        // },
        xAxis: [
          { type: "category", 
          data: this.bar1data.lyName }
        ],
        yAxis: {
          name: "关\n键\n技\n术\n数\n量",
          nameLocation: "left",
          nameTextStyle: {
            color: "#fff",
            fontSize: 14,
            // padding: [0, 40, -100, 0],
          },
        },
        // Declare several bar series, each will be mapped
        // to a column of dataset.source by default.
        series: [
          {
            name: 'A',
            type: "bar",
            barWidth: "10%",
            data: this.bar1data.A,
            itemStyle: {
              normal: {
                color: '#2f6ac6',
                barBorderRadius: [20, 20, 20, 20],
              },
            },
          },
          {
            name: 'B',
            type: "bar",
            barWidth: "7%",
            data: this.bar1data.B,
            itemStyle: {
              normal: {
                color: '#4caee4',
                barBorderRadius: [20, 20, 20, 20],
              },
            },
          },
          {
            name: 'C',
            type: "bar",
            barWidth: "7%",
            data: this.bar1data.C,
            itemStyle: {
              normal: {
                color: '#97d5dd',
                barBorderRadius: [20, 20, 20, 20],
              },
            },
          },
        ],
      });
    },
  },
};
</script>

<style>
</style>